/**

 @author 石头哥哥
 </P>
 Date:   2014/12/26
 </P>
 Time:   14:02

 注解：

 */
package view {
import feathers.controls.renderers.LayoutGroupListItemRenderer;

import starling.display.Shape;
import starling.events.Touch;
import starling.events.TouchEvent;
import starling.events.TouchPhase;
import starling.text.TextField;


import starling.utils.Color;


/**
 *
 */
public class TestRenderer extends LayoutGroupListItemRenderer {


    //测试显示文字
    private var textShow:TextField;

    /**
     * 针对一条数据的渲染处理
     *
     * 定制渲染器
     *
     * 显示的数据
     *
     * 位置 等信息
     */
    public function TestRenderer() {
        super();

        var shape:Shape = new Shape();

        shape.graphics.beginFill(Color.WHITE);
        shape.graphics.drawRect(50, 50, 250, 50);
        addChild(shape);

        textShow = new TextField(250, 100, "", "Verdana", 24, Color.RED);

        shape.addChild(textShow);

        /**
         *
         */
        shape.addEventListener(TouchEvent.TOUCH, function (e:TouchEvent):void {
            var touch:Touch = e.getTouch(e.currentTarget as Shape, TouchPhase.ENDED);
            if (touch) {
                trace("touched!,dispatchEventWith change ");
                isSelected = true;// will dispatcher event change
            }
        });

    }

    /**
     *
     */
    override public function dispose():void {
        super.dispose();

        /**
         * dispose some data
         */

    }

    /**
     * render before  , fill data
     * @param $value
     */
    override public function set data($value:Object):void {
        this._data = $value;
        if ($value) {
            textShow.text = $value["id"];
            trace($value["id"]);
        }
    }
}
}
